Transects
|
Plant
|
Flowers
|
Date
|
lon
|
lat
|
ele
|
Month
|
Year
|
julian
|
|
Glossoloma oblongicalyx
|
4
|
2015-10-19
|
-78.59093
|
0.130838
|
2270
|
October
|
2015
|
292
|
|
Gasteranthus quitensis
|
2
|
2016-10-17
|
-78.59770
|
0.120070
|
1940
|
October
|
2016
|
291
|
|
Kohleria affinis
|
1
|
2016-12-13
|
-78.59534
|
0.126746
|
2110
|
December
|
2016
|
348
|
|
Columnea ciliata
|
3
|
2014-02-27
|
-78.59934
|
0.116682
|
1960
|
February
|
2014
|
58
|
|
Columnea medicinalis
|
1
|
2014-04-23
|
-78.59372
|
0.128700
|
2130
|
April
|
2014
|
113
|
|
Drymonia teuscheri
|
3
|
2016-07-28
|
-78.59245
|
0.129393
|
2200
|
July
|
2016
|
210
|
Phylogeny

Traits
|
Plant
|
Flowers
|
Date
|
lon
|
lat
|
ele
|
Month
|
Year
|
julian
|
|
Glossoloma oblongicalyx
|
4
|
2015-10-19
|
-78.59093
|
0.130838
|
2270
|
October
|
2015
|
292
|
|
Gasteranthus quitensis
|
2
|
2016-10-17
|
-78.59770
|
0.120070
|
1940
|
October
|
2016
|
291
|
|
Kohleria affinis
|
1
|
2016-12-13
|
-78.59534
|
0.126746
|
2110
|
December
|
2016
|
348
|
|
Columnea ciliata
|
3
|
2014-02-27
|
-78.59934
|
0.116682
|
1960
|
February
|
2014
|
58
|
|
Columnea medicinalis
|
1
|
2014-04-23
|
-78.59372
|
0.128700
|
2130
|
April
|
2014
|
113
|
|
Drymonia teuscheri
|
3
|
2016-07-28
|
-78.59245
|
0.129393
|
2200
|
July
|
2016
|
210
|
Total Flowers
Peak date


Infer absences

Species elevation ranges

Species by transect matrix

Count model of species phenology
## sink("model/occ_baseline.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(alpha[Plant[x]])
##
## #Residuals
## discrepancy[x] <- pow(Y[x] - alpha[Plant[x]],2)
##
## #Assess Model Fit
## Ynew[x] ~ dbern(alpha[Plant[x]])
## discrepancy.new[x]<-pow(Ynew[x] - alpha[Plant[x]],2)
##
## }
##
## #Sum discrepancy
## fit<-sum(discrepancy)
## fitnew<-sum(discrepancy.new)
##
## #Prediction
##
## for(i in 1:Npreds){
##
## #predict value
##
## #Observation - probability of flowering
## prediction[i] ~ dbern(alpha[Ypred_plant[i]])
##
## #squared predictive error
## pred_error[i] <- pow(Ypred[i] - prediction[i],2)
## }
##
## #Predictive Error
## fitpred<-sum(pred_error)
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
##
## #Intercept
## #Intercept flowering count
## alpha[j] ~ dbeta(1,1)
##
## }
##
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 2926
## Unobserved stochastic nodes: 3444
## Total graph size: 17231
##
## Initializing model
Evaluate convergence


Posterior estimates

Error by elevation for estimated data

Phylogeny
Attraction
## sink("model/occ_attraction.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x]] + e[Plant[x],Date[x]]
##
## #Residuals
## discrepancy[x] <- pow(Y[x] - alpha[Plant[x]],2)
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-pow(Ynew[x] - alpha[Plant[x]],2)
##
## }
##
## #Sum discrepancy
## fit<-sum(discrepancy)
## fitnew<-sum(discrepancy.new)
##
## #Prediction
##
## for(i in 1:Npreds){
##
## #predict value
##
## #Observation - probability of flowering
## prediction[i] ~ dbern(p_new[i])
## logit(p_new[i])<-alpha[Ypred_plant[i]] + e[Ypred_plant[i],Ypred_date[i]]
##
## #squared predictive error
## pred_error[i] <- pow(Ypred[i] - prediction[i],2)
## }
##
## #Predictive Error
## fitpred<-sum(pred_error)
##
## #########################
## #autocorrelation in error
## #########################
##
## #For each of observation
## for(k in 1:Dates){
## e[1:Plants,k] ~ dmnorm(zeros[],tauC[,])
## }
##
## ##covariance among similiar species
## for(i in 1:Plants){
## for(j in 1:Plants){
## C[i,j] = exp(-lambda_cov * D[i,j])
## }
## }
##
## ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
## vCov = omega*C[,] + (1-omega) * I
## tauC=inverse(vCov*gamma)
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
##
## #Intercept
## #Intercept flowering count
## alpha[j] ~ dnorm(0,0.386)
##
## }
##
## #Autocorrelation priors
## gamma ~ dunif(0,20)
##
## #Strength of covariance decay
## lambda_cov = 5
## omega ~ dbeta(1,1)
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 2926
## Unobserved stochastic nodes: 3691
## Total graph size: 31647
##
## Initializing model
Get Chains
Evaluate convergence


Posterior estimates

Decay in phylogenetic attraction

Repulsion
## sink("model/occ_repulsion.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x]] + e[Plant[x],Date[x]]
##
## #Residuals
## discrepancy[x] <- pow(Y[x] - alpha[Plant[x]],2)
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-pow(Ynew[x] - alpha[Plant[x]],2)
##
## }
##
## #Sum discrepancy
## fit<-sum(discrepancy)
## fitnew<-sum(discrepancy.new)
##
## #Prediction
##
## for(i in 1:Npreds){
##
## #predict value
##
## #Observation - probability of flowering
## prediction[i] ~ dbern(p_new[i])
## logit(p_new[i])<-alpha[Ypred_plant[i]] + e[Ypred_plant[i],Ypred_date[i]]
##
## #squared predictive error
## pred_error[i] <- pow(Ypred[i] - prediction[i],2)
## }
##
## #Predictive Error
## fitpred<-sum(pred_error)
##
## #########################
## #autocorrelation in error
## #########################
##
## #For each of observation
## for(k in 1:Dates){
## e[1:Plants,k] ~ dmnorm(zeros[],tauC[,])
## }
##
## ##covariance among similiar species
## for(i in 1:Plants){
## for(j in 1:Plants){
## C[i,j] = exp(-lambda_cov * D[i,j])
## }
## }
##
## ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
## vCov = omega*C[,] + (1-omega) * I
## tauC=vCov*gamma
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
##
## #Intercept
## #Intercept flowering count
## alpha[j] ~ dnorm(0,0.386)
##
## }
##
## #Autocorrelation priors
## gamma ~ dunif(0,20)
##
## #Strength of covariance decay
## lambda_cov = 5
## omega ~ dbeta(1,1)
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 2926
## Unobserved stochastic nodes: 3691
## Total graph size: 31646
##
## Initializing model
Get Chains
Evaluate convergence


Posterior estimates

Decay in phylogenetic repulsion

Traits
Trait Attraction
## sink("model/occ_attraction.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x]] + e[Plant[x],Date[x]]
##
## #Residuals
## discrepancy[x] <- pow(Y[x] - alpha[Plant[x]],2)
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-pow(Ynew[x] - alpha[Plant[x]],2)
##
## }
##
## #Sum discrepancy
## fit<-sum(discrepancy)
## fitnew<-sum(discrepancy.new)
##
## #Prediction
##
## for(i in 1:Npreds){
##
## #predict value
##
## #Observation - probability of flowering
## prediction[i] ~ dbern(p_new[i])
## logit(p_new[i])<-alpha[Ypred_plant[i]] + e[Ypred_plant[i],Ypred_date[i]]
##
## #squared predictive error
## pred_error[i] <- pow(Ypred[i] - prediction[i],2)
## }
##
## #Predictive Error
## fitpred<-sum(pred_error)
##
## #########################
## #autocorrelation in error
## #########################
##
## #For each of observation
## for(k in 1:Dates){
## e[1:Plants,k] ~ dmnorm(zeros[],tauC[,])
## }
##
## ##covariance among similiar species
## for(i in 1:Plants){
## for(j in 1:Plants){
## C[i,j] = exp(-lambda_cov * D[i,j])
## }
## }
##
## ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
## vCov = omega*C[,] + (1-omega) * I
## tauC=inverse(vCov*gamma)
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
##
## #Intercept
## #Intercept flowering count
## alpha[j] ~ dnorm(0,0.386)
##
## }
##
## #Autocorrelation priors
## gamma ~ dunif(0,20)
##
## #Strength of covariance decay
## lambda_cov = 5
## omega ~ dbeta(1,1)
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 2926
## Unobserved stochastic nodes: 3691
## Total graph size: 31803
##
## Initializing model
Get Chains
Evaluate convergence


Posterior estimates

Decay in trait attraction

Repulsion
## sink("model/occ_repulsion.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x]] + e[Plant[x],Date[x]]
##
## #Residuals
## discrepancy[x] <- pow(Y[x] - alpha[Plant[x]],2)
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-pow(Ynew[x] - alpha[Plant[x]],2)
##
## }
##
## #Sum discrepancy
## fit<-sum(discrepancy)
## fitnew<-sum(discrepancy.new)
##
## #Prediction
##
## for(i in 1:Npreds){
##
## #predict value
##
## #Observation - probability of flowering
## prediction[i] ~ dbern(p_new[i])
## logit(p_new[i])<-alpha[Ypred_plant[i]] + e[Ypred_plant[i],Ypred_date[i]]
##
## #squared predictive error
## pred_error[i] <- pow(Ypred[i] - prediction[i],2)
## }
##
## #Predictive Error
## fitpred<-sum(pred_error)
##
## #########################
## #autocorrelation in error
## #########################
##
## #For each of observation
## for(k in 1:Dates){
## e[1:Plants,k] ~ dmnorm(zeros[],tauC[,])
## }
##
## ##covariance among similiar species
## for(i in 1:Plants){
## for(j in 1:Plants){
## C[i,j] = exp(-lambda_cov * D[i,j])
## }
## }
##
## ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
## vCov = omega*C[,] + (1-omega) * I
## tauC=vCov*gamma
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
##
## #Intercept
## #Intercept flowering count
## alpha[j] ~ dnorm(0,0.386)
##
## }
##
## #Autocorrelation priors
## gamma ~ dunif(0,20)
##
## #Strength of covariance decay
## lambda_cov = 5
## omega ~ dbeta(1,1)
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 2926
## Unobserved stochastic nodes: 3691
## Total graph size: 31802
##
## Initializing model
Get Chains
Evaluate convergence


Posterior estimates

Decay in trait repulsion

Model Comparison
Alpha

E: The effect of autocorrelation on mean flowering intensity

Omega: The magnitude of the effect of autocorrelation on mean flowering intensity

Gamma: The variance of the effect of autocorrelation on mean flowering intensity

Effect of autocorrelation

Decay in autocorrelation effect

Model Fit
Bayesian pvalue

## # A tibble: 5 x 2
## Model p
## <chr> <dbl>
## 1 baseline 0.456
## 2 phylogenetic_attraction 0.535
## 3 phylogenetic_repulsion 0.525
## 4 trait_attraction 0.551
## 5 trait_repulsion 0.494
Overall

By Species

Zoom in
#Prediction

Out of sample data
